//
//  photoViewController.m
//  项目一
//
//  Created by nick on 15/7/23.
//  Copyright (c) 2015年 nick. All rights reserved.
//

#import "photoViewController.h"
#define sheight [UIScreen mainScreen].bounds.size.height
#define swidth [UIScreen mainScreen].bounds.size.width
#define sNavHeight 64
#define sTabBarHeight 49
@interface photoViewController (){
    photoCollectionView *photocv;
}

@end

@implementation photoViewController

- (void)_createCollectionView{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    layout.itemSize = self.view.bounds.size;
    layout.minimumLineSpacing = 30;
    photocv = [[photoCollectionView alloc]initWithFrame:CGRectMake(0, 0, swidth+30, sheight) collectionViewLayout:layout];
    photocv.imageUrlArray = _imageUrlArray;
    [self.view addSubview:photocv];

    
    
}

- (void)_setNavigationBar{
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(btnAction)];
}
- (void)btnAction{
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    //self.view.backgroundColor = [UIColor yellowColor];
    [self _setNavigationBar];
    [self _createCollectionView];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(notificationAction) name:@"hidenNavigationBar" object:nil];
    NSIndexPath *indexpath = [NSIndexPath indexPathForRow:self.index inSection:0];
    [photocv scrollToItemAtIndexPath:indexpath atScrollPosition:UICollectionViewScrollPositionLeft animated:YES];
    // Do any additional setup after loading the view.
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)notificationAction{
    BOOL ishiden = self.navigationController.navigationBar.isHidden;
    if (ishiden == YES) {
        [self.navigationController setNavigationBarHidden:NO animated:YES];
        
        
    }
    else{
        [self.navigationController setNavigationBarHidden:YES animated:YES];
        
    }
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
